package com.minimalist.basic.service;

import com.minimalist.basic.manager.UserManager;
import com.minimalist.common.entity.lindi.vo.tradeapplicationoperator.LindiTradeApplicationOperatorVO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author 11987
 */
@Component
public class LindiTradeApplicationOperatorService{

    @Resource
    private UserManager userManager;

    public List<LindiTradeApplicationOperatorVO> getCreatorNameByTradeApplicationOperatorList(
            List<LindiTradeApplicationOperatorVO> tradeApplicationOperatorList){
        Map<Long, String> map = userManager.getUserNameByUserId(
                tradeApplicationOperatorList.stream()
                        .map(LindiTradeApplicationOperatorVO::getCreateId).toList());
        tradeApplicationOperatorList.forEach(
                tradeApplicationOperator ->
                        tradeApplicationOperator.setCreatorName(map
                                .get(tradeApplicationOperator.getCreateId())));
        return tradeApplicationOperatorList;
    }
}
